<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            X-admin v1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/admin/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>老师管理</cite></a>
              <a><cite>成功案例</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
            
            <xblock>
                <button class="layui-btn" onclick="role_add('添加案例','{:U('admin/laoshi/success_index',array('id'=>$id))}','700','550')"><i class="layui-icon">&#xe608;</i>添加</button>
            </xblock>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>
                        <th>
                            学生
                        </th>
                        <th>
                            时间
                        </th>
                        <th>
                            成果
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($success as $s) { ?>
                    <tr>
                        <td>
                            {$s.id}
                        </td>
                        <td>
                            {$s.stu_name}
                        </td>
                        <td >
                            {$s.time_year}-{$s.time_month}
                        </td>
                        <td >
                            <?php echo htmlspecialchars_decode($s['result']) ?>
                        </td>
                        <td class="td-manage">
                            <a title="编辑" href="javascript:;" onclick="role_edit('编辑','{:U('admin/laoshi/success_edit_index',array('id'=>$s['id']))}','4','','500')"
                            class="ml-5" style="text-decoration:none"><i class="layui-icon">&#xe642;</i></a>
                            <a title="删除" href="javascript:;" onclick="role_del(this,'{$s['id']}')" style="text-decoration:none"><i class="layui-icon">&#xe640;</i></a>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>

            <div id="page"></div>
        </div>
        <script src="__PUBLIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="__PUBLIC__/admin/js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use(['laydate','element','laypage','layer'], function(){
                $ = layui.jquery;//jquery
              laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层

              //以上模块根据需要引入
            });


             /*添加*/
            function role_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }

             
            //编辑
            function role_edit (title,url,id,w,h) {
                x_admin_show(title,url,w,h); 
            }

            /*彻底删除*/
            function role_del(obj,id){
                layer.confirm('确认要删除数据吗？',function(index){
                    //发异步删除数据
                     id = id;
                    $.ajax({
                        url: "{:U('admin/laoshi/success_delete')}",//请求地址
                        type: "post",//请求方式
                        dataType: "json",//返回数据类型
                        data: {id:id},//发送的参数
                        })
                        .done(function(response) {
                              if(response.error==1){
                                layer.msg(response.info ,{icon:6});
                                $(obj).parents("tr").remove();
                              }else{
                                layer.msg(response.info ,{icon:5});
                              }
                          })
                        .fail(function() {
                            alert("ajxs交互失败");
                        })  
                    return false;   
                });
            }
            </script>
    </body>
</html>